package UIFree.controls
{
	import UIFree.controls.uif_cross;
	import UIFree.uif_component;
	
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;

	public class uif_close extends uif_cross {
		public function uif_close(parent: uif_component, ax: int=0, ay: int=0) {
			super(parent, ax?ax:(parent.width - 18), ay?ay:- 18, 20, 20, 'closeButton');
			addEvent(MouseEvent.CLICK, function(e: MouseEvent): void {
				parent.dispatchEvent(new Event(Event.CLOSE));
			});
			
			addEvent(KeyboardEvent.KEY_DOWN, function (e: KeyboardEvent): void {
				if (e.keyCode == 27) parent.dispatchEvent(new Event(Event.CLOSE));
			}, stage);
		}
		
	}
}